﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Hangjing.Common;
using Hangjing.SQLServerDAL;
using Hangjing.Model;
using Hangjing.DBUtility;
using System.Collections.Generic;

/// <summary>
/// 通过js 加载数据
/// </summary>
public partial class qy_54tss_Admin_GpsSet_OrderCrmSuper : System.Web.UI.Page
{
    Points daltogo = new Points();
    Custorder dal = new Custorder();
    City dalcity = new City();
    protected string _sortname
    {
        set
        {
            ViewState["_sortname"] = value;
        }
        get
        {
            return ViewState["_sortname"] == null ? "sortnum" : ViewState["_sortname"].ToString();
        }
    }

    protected int _sortflag
    {
        set
        {
            ViewState["_sortflag"] = value;
        }
        get
        {
            return ViewState["_sortflag"] == null ? 0 : Convert.ToInt32(ViewState["_sortflag"].ToString());
        }
    }


    protected string sqlWhere
    {
        set
        {
            ViewState["sqlWhere"] = value;
        }
        get
        {
            return ViewState["sqlWhere"] == null ? "" : ViewState["sqlWhere"].ToString();
        }
    }

    /// <summary>
    /// 订单语句
    /// </summary>
    protected string ordersqlWhere
    {
        set
        {
            ViewState["ordersqlWhere"] = value;
        }
        get
        {
            return ViewState["ordersqlWhere"] == null ? "" : ViewState["ordersqlWhere"].ToString();
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //清楚地址编号cookie
            if (Request["user"] != null)
            {
                string uname = WebUtility.InputText(Request["user"]);
                string password = WebUtility.GetMd5(Request["p"]);
                EAdminInfo model = new EAdmin().GetModel(uname, password);
                UserHelp.AdminLogin(model);
            }
          
            sqlWhere = "  1=1 and IsDelete = 0 and Star = 1 and InUse = 'Y' and delflag = 0 ";
            

            EAdminInfo admin = UserHelp.GetAdmin();
            if (admin == null)
            {
                Response.Redirect("/Admin/login.aspx");
            }
            string cityname = "全国";

            if (admin.CityID > 0)
            {
                foreach (var item in CacheHelper.GetCityList())
                {
                    if (item.cid == admin.CityID)
                    {
                        cityname = item.cname;
                        break;
                    }
                }
                sqlWhere += " and cityid=" + admin.CityID;
            }
            hfcityid.Value = admin.CityID.ToString();
            hidUid.Value = admin.ID.ToString();
            hfcityname.Value = cityname;
            string cityid = WebUtility.FixgetCookie("admin_cityid");

            hfsqlwhere.Value= sqlWhere;

            string usercode = WebUtility.FixgetCookie("uc");
            if (usercode == null || usercode == "")
            {
                usercode = WebUtility.GetRandom(10);
                WebUtility.FixsetCookie("uc", usercode, 1);
            }

            //热门商家
            WebUtility.BindRepeater(rpthot, CacheHelper.GetAdminHotShops(admin.CityID));

        }
    }


}
